package lanqiao;

public class test_2 {
    static int[] d = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    public static boolean isR(int year) {
        if ( (year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
            return true;
        }
        return false;
    }
    
    public static void main(String[] args) {
        int cnt = 0;
        for (int y = 1900; y <= 9999; y ++ ) {
            for (int m = 1; m <= 12; m ++ ) {
                for (int day = 1; day <= d[m - 1]; day ++ ){
                    if (m == 2 && !isR(y) && day > 28) continue;
                    int y1, y2, y3, y4;
                    y1 = y / 1000;
                    y2 = y / 100 % 10;
                    y3 = y / 10 % 10;
                    y4 = y % 10;
                    int m1, m2;
                    m1 = m / 10;
                    m2 = m % 10;
                    int d1, d2;
                    d1 = day / 10;
                    d2 = day % 10;
                    if (y1 + y2 + y3 + y4 == m1 + m2 + d1 + d2) cnt ++ ;
                }
            }
        }
        System.out.println(cnt);
    }
    
}
